package org.jeecg.modules.business.service.impl;


import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.business.entity.BusMarketMember;
import org.jeecg.modules.business.mapper.BusMarketMemberMapper;
import org.jeecg.modules.business.service.IBusMarketMemberService;
import org.jeecg.modules.rooms.Vo.SelectVo;
import org.jeecg.modules.rooms.entity.CesRoomPricePlan;
import org.jeecg.modules.rooms.mapper.CesRoomPricePlanMapper;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description: bus_market_member_info
 * @Author: jeecg-boot
 * @Date:   2023-03-02
 * @Version: V1.0
 */
@Service
public class BusMarketMemberServiceImpl extends ServiceImpl<BusMarketMemberMapper, BusMarketMember> implements IBusMarketMemberService {
    @Resource
    private BusMarketMemberMapper busMarketMemberMapper;

    /**
     * 排除当前id查询列表
     * @param id
     * @return
     */
    public Result getList(String id,String hotelId){
        List<BusMarketMember> list =  busMarketMemberMapper.selectList(Wrappers.<BusMarketMember>lambdaQuery()
                .ne(BusMarketMember::getId,id)
                .eq(StringUtils.isNotEmpty(hotelId),BusMarketMember::getHotelId,hotelId)

        );
        if(CollectionUtil.isEmpty(list)) return Result.ok(new ArrayList<>());
        List<SelectVo> vos = new ArrayList<>();
        list.forEach(v -> {
            SelectVo vo = new SelectVo();
            vo.setLabel(v.getName());
            vo.setValue(v.getId());
            vos.add(vo);
        });
        return Result.ok(vos);
    }

    public List<BusMarketMember> getByIds(List<String> ids,String hotelId){
        if(CollectionUtil.isEmpty(ids) || StringUtils.isBlank(hotelId)) return new ArrayList<>();
        List<BusMarketMember> list =  busMarketMemberMapper.selectList(Wrappers.<BusMarketMember>lambdaQuery().in(BusMarketMember::getId,ids).eq(BusMarketMember::getHotelId,hotelId));
        return list;
    }
}
